<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'user-index', //页面标示
    'pagename' => '群组列表', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/jquery.smoothConfirm'),
    'head' => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
  <section id="content">
    <!-- main padder --> 
    <section class="main padder">
        <div class="clearfix"> 
			<h4><i class="fa fa-table"></i><?php echo trim($Document['pagename'],'_');?></h4> 
        </div>
        <div class="row">
			<!-- table 11 -->
			<div class="col-lg-12"> 
            <!---->
          <div class="panel-body">
            <div class="row text-small">
              <div class="col-sm-8">
                <div data-resize="auto" class="select btn-group" style="margin-left:10px"> 
                  <button class="btn btn-white dropdown-toggle" data-toggle="dropdown" type="button"><span class="dropdown-label">新建群组</span> <span class="caret"></span></button> 
                <ul class="dropdown-menu">
				<li><a href="<?php echo U('wxgroup/add');?>">普通群组</a></li>
				<li><a href="<?php echo U('wxgroup/field_add');?>">站点固定群组</a></li>
                </ul>
                </div>

               <div data-resize="auto" class="select btn-group" style="margin-left:10px"> 
                  <button class="btn btn-white dropdown-toggle" data-toggle="dropdown" type="button"><span class="dropdown-label">群组类型</span> <span class="caret"></span></button> 
                <ul class="dropdown-menu">
				<li><a href="<?php echo U('wxgroup/field');?>">类型管理</a></li>
                <li data-value="0" <?php if(!$fieldid){echo 'class="active"';}?>><a href="<?php echo U('wxgroup/index');?>">全部</a></li>
                <?php
                foreach($fieldlist as $key=>$val){
                ?>
                 <li data-value="<?php echo ($val['fieldid']);?>" <?php if($fieldid==($val['fieldid'])){echo 'class="active"';}?>><a href="<?php echo U('wxgroup/index',array('fieldid'=>($val['fieldid'])));?>"><?php echo $val['title'];?></a></li>
                <?php
                }
                ?>
                </ul>
                </div>
              </div>
              <div class="col-sm-4">
                <form action="<?php echo U(ACTION_NAME.'/index');?>" method="get" name="form1" target="_self">
                  <div class="input-group">
                    <input type="text" name="q" class="input-sm form-control" placeholder="请输入帐号名关键字..." />
                    <!--<input name="g" type="hidden" value="<?php echo GROUP_NAME;?>" />
                    <input name="c" type="hidden" value="<?php echo ACTION_NAME;?>" />
                    <input name="m" type="hidden" value="<?php echo MODEL_NAME;?>" />-->
                    <span class="input-group-btn">
                    <button class="btn btn-sm btn-white" type="submit">搜索</button>
                    </span> </div>
                </form>
              </div>
            </div>
          </div>
          <!---->
				<section class="panel"> 
					<div class="table-responsive"> 
						<table class="table table-striped b-t text-small"> 
							<thead>
                              <tr>
                                <th align="center" style=" text-align:center;">ID</th>
                                <th align="center" style=" text-align:center;">群组名称</th>
								<th align="center" style=" text-align:center;">群组类型</th>
								<th align="center" style=" text-align:center;">群组头像</th>
								<th align="center" style=" text-align:center;">所在小区</th>
								<th align="center" style=" text-align:center;">人数</th>
								<!--<th align="center" style=" text-align:center;">主题数</th>
								<th align="center" style=" text-align:center;">回复数</th>-->
								<th align="center" style=" text-align:center;">群主</th>
								<th align="center" style=" text-align:center;">创建时间</th>
								<th align="center" style=" text-align:center;">群组状态</th>
                                <!--<th align="center">帐号</th>
                                <th align="center">商圈</th>
                                <th align="center">手机</th>
                                <th align="center">登陆次数</th>
                                <th align="center">最后登陆时间</th>
                                <th align="center">登陆IP</th>
                                <th align="center">注册时间</th>
                                <th align="center">有效截止期</th>
                                <th align="center">组别</th>
                                <th align="center">帐号状态</th>
                                <th align="center">工作状态</th>-->
                                <th align="center" width="120">操作</th>
                              </tr>
                            </thead>
                            <tbody>
                            <?php
                            if ($rs){
                                foreach($rs as $val){
                            ?>
                              <tr id="list_detail_<?php echo $val['groupid'];?>">
                                <td align="center"><?php echo $val['groupid'];?></td>
                                <td align="center"><?php echo $val['groupname'];?></td>
								<td align="center"><?php echo $fieldnames[$val['fieldid']];?></td>
								<td align="center"><img src="<?php if($val['pic']){echo $val['pic'];}else{echo "http://img.51jhome.com/yun/avatar/noavatar_big.jpg";}?>" style="width:60px; height:60px;border-radius:40px;" /></td>
								<td align="center"><a href="http://api.map.baidu.com/marker?location=<?php echo $val['group_lat'];?>,<?php echo $val['group_lon'];?>&title=<?php echo $val['groupname'];?>&content=<?php echo $val['vtitle'];?>&output=html&src=weiba|weiweb" target="_blank"><?php echo $val['vtitle'];?></a></td>
								<td align="center"><?php echo $val['membernum'];?></td>
								<!--<td align="center"><?php echo $val['threadnum'];?></td>
								<td align="center"><?php echo $val['postnum'];?></td>-->
								<td align="center"><?php echo $val['moderator'];?></td>
								<td align="center"><?php echo date('Y-m-d H:i:s',$val['currenttime']);?></td>
								<td align="center" class="closetd"><?php if($val['close']){ ?><span class="red">锁定</span><?php }else{?><span class="green">正常</span><?php } ?></td>
                                <!--<td><?php echo $val['username'];?></td>
                                <td><?php echo $val['areaName'];?></td>
                                <td><?php echo $val['phone'];?></td>
                                <td><?php echo $val['logincount'];?></td>
                                <td><?php echo ($val['logintime']?outTime($val['logintime']):'');?></td>
                                <td><?php echo long2ip($val['loginip']);?></td>
                                <td><?php echo ($val['regdateline']?outTime($val['regdateline']):'');?></td>
                                <td><?php echo ($val['effective']?outTime($val['effective'],2):'长期');?></td>
                                <td><?php echo $group[$val['groupid']];?></td>
                                <td><?php echo $setting['user_status'][$val['status']];?></td>
                                <td id="work-status-<?php echo $val['user_id'];?>"><?php echo $setting['work_status'][$val['work_status']];?></td>-->
                                <td align="center">
                                <div class="btn-group"> 
                                    <button class="btn btn-white btn-xs dropdown-toggle" data-toggle="dropdown">操作<span class="caret"></span></button> 
                                     <ul class="dropdown-menu" style="width:95px">
                                       <li class="dropdown-submenu pull-left"><a href="#" tabindex="-1">状态切换</a> 
                                             <ul aria-labelledby="dropdownMenu" role="menu" class="dropdown-menu" style="margin-left:25px">
                                              <li><a href="javascript:;" class="setting-status" act="0" rel="<?php echo $val['groupid'];?>" tabindex="-1">正常</a></li>
											  <li><a href="javascript:;" class="setting-status" act="1" rel="<?php echo $val['groupid'];?>" tabindex="-1">锁定</a></li> 
                                             </ul>
                                         </li>
                     					<li class="divider"></li>
                                        <li><a href="<?php echo U('user/edit',array('id'=>$val['user_id']));?>">编辑</a></li> 
                                        <li><a href="javascript:;" rel="<?php echo $val['user_id'];?>" class="delete">删除</a></li>
                                    </ul> 
								</div>
                                </td>
                              </tr>
                              <?php
                                }
                            }else{
                              ?>
                             <tr>
                                <td colspan="8" align="center">暂无数据</td>
                              </tr>
                            <?php
                            }
                            ?>
                            </tbody> 
						</table> 
					</div> 
         			<footer class="panel-footer">
                    <div class="row">
                      <div class="col-sm-12 text-right text-center-sm">
                        <?php echo page($total,$p,'',20,'p');?></div>
                    </div>
                  </footer>
				</section> 
			</div> 
			<!--/ table 11 -->

        </div> 
    </section>
    <!--/ main padder -->  
  </section> 
  <!--/ content --> 
<!--主体 结束-->
<script>
$(function(){
	$('.delete').click(function(){
		var id=$(this).attr('rel');
	  $(this).smoothConfirm("确认删除该帐户吗？", {
		  ok: function() {
			  Msg.loading();
			  $.post('<?php echo U('user/delete');?>',{"id":id},function(result){
				  Msg.hide();
				  if (result.status==1){
					  $("#list_detail_"+id).fadeOut();
				   }else{
					  Msg.error(result.info);
				  }
			  },'json');
		  },
		  cancel: function() {
			  return false;
		  }
	  });
	  $("body").click();//取消弹出层对对话框的遮蔽
	  return false;
	});
	$(".setting-status").click(function(){
		var id=$(this).attr('rel'),act=$(this).attr('act');
	  	Msg.loading();
		$.post('<?php echo U('wxgroup/index');?>',{"id":id,"act":act},function(result){
			Msg.hide();
			if (result.status==1){
				shtml=(act==1)?'<span class="red">锁定</span>':'<span class="green">正常</span>';
				$("#list_detail_"+id+" .closetd").html(shtml);
				//$("#work-status-"+id).html(result.data);
			}else{
				Msg.error(result.info);
			}
		},'json');
	  $("body").click();
	  return false;
	})
})
</script>
<?php
include getTpl('footer', 'public');
?>